import request from '@/utils/axios-req'
const SERVERURL = import.meta.env.VITE_APP_BASE_MIAN_URL
// const SERVERURL = "http://localhost:8000"
// ### 获取管理员token
export const usrLogin = ({ username, password }) => {
  return request({
    url: `${SERVERURL}/auth/token`,
    reqLoading: false,
    method: 'post',
    data: {
      username,
      password
    }
  })
}

// ### 获取管理员个人信息
export const getUsrInfo = () => {
  return request({
    url: `${SERVERURL}/auth/me`,
    reqLoading: false,
    method: 'get'
  })
}

// ### 更改管理员密码
export const changepassword = ({ password }) => {
  return request({
    url: `${SERVERURL}/auth/changepassword`,
    reqLoading: false,
    method: 'put',
    data: {
      password
    }
  })
}

// ### 更改管理员用户名
export const changeusername = ({ username }) => {
  return request({
    url: `${SERVERURL}/auth/changeusername`,
    reqLoading: false,
    method: 'put',
    data: {
      username
    }
  })
}

// ### 更改管理员邮箱
export const changeemail = ({ email }) => {
  return request({
    url: `${SERVERURL}/auth/changeemail`,
    reqLoading: false,
    method: 'put',
    data: {
      email
    }
  })
}

// ### 更改管理员手机号
export const changephone = ({ phone }) => {
  return request({
    url: `${SERVERURL}/auth/changephone`,
    reqLoading: false,
    method: 'put',
    data: {
      phone // "+8618700002215"
    }
  })
}

// ### 更改管理员名称
export const changename = ({ name }) => {
  return request({
    url: `${SERVERURL}/auth/changename`,
    reqLoading: false,
    method: 'put',
    data: {
      name
    }
  })
}

// ### 一次更改管理员用户名、密码，邮箱，手机号，名称
export const changeprofile = ({ username, password, email, phone, name }) => {
  return request({
    url: `${SERVERURL}/auth/changeprofile`,
    reqLoading: false,
    method: 'put',
    data: {
      username,
      password,
      email,
      phone, // +8618700002216
      name
    }
  })
}


// ### 获取管理员token
// POST http://localhost:8000/auth/token
// content-type: application/json

// {
//   "username": "superman01",
//   "password": "supermannofly"
// }

// ### 获取普通用户token
// POST http://localhost:8000/auth/token
// content-type: application/json

// {
//   "username": "jay32221",
//   "password": "jaypassword23"
// }

// ### 获取普通用户token
// POST http://localhost:8000/auth/token
// content-type: application/json

// {
//   "username": "jay32221",
//   "password": "jaypassword23"
// }

// ### 获取管理员个人信息
// GET http://localhost:8000/auth/me
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyMSIsImV4cCI6MTcxNTEwMjA0OX0.7xasAwkPdVvzNxoBIrTDMkbm_FNrLSi9_8K5_y5GdkI


// ### 更改管理员用户密码
// PUT http://localhost:8000/auth/changepassword
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwNzY4fQ.1rHShqWCeLavAAj6abo6nSVNA84zB_VunQaUCjJQGfU

// {
// 	"password": "jaypassword2"
// }

// ### 更改管理员用户名
// PUT http://localhost:8000/auth/changeusername
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwODA0fQ._CVCLRW2YnI9UM1tXB_IzeZYpnQ_eKd7u9H7I05c-IE 

// {
// 	"username": "jay3222"
// }

// ### 更改管理员邮箱
// PUT http://localhost:8000/auth/changeemail
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwODA0fQ._CVCLRW2YnI9UM1tXB_IzeZYpnQ_eKd7u9H7I05c-IE

// {
// 	"email": "2@qq.com"
// }

// ### 更改管理员手机号
// PUT http://localhost:8000/auth/changephone
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwODA0fQ._CVCLRW2YnI9UM1tXB_IzeZYpnQ_eKd7u9H7I05c-IE

// {
// 	"phone": "+8618700002215"
// }

// ### 更改管理员名称
// PUT http://localhost:8000/auth/changename
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwODA0fQ._CVCLRW2YnI9UM1tXB_IzeZYpnQ_eKd7u9H7I05c-IE

// {
// 	"name": "Jay Lee"
// }

// ### 一次更改管理员用户名、密码，邮箱，手机号，名称
// PUT http://localhost:8000/auth/changeprofile
// Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqYXkzMjIyIiwiZXhwIjoxNzE1MTAwODA0fQ._CVCLRW2YnI9UM1tXB_IzeZYpnQ_eKd7u9H7I05c-IE

// {
// 	"username": "jay32221",
// 	"password": "jaypassword23",
// 	"email": "3@qq.com",
// 	"phone": "+8618700002216",
// 	"name": "Jay Lee 2"
// }